package com.ven.simple.autoci

import com.ven.assists.AssistsCore
import com.ven.assists.AssistsCore.click
import com.ven.assists.AssistsCore.setNodeText
import com.ven.assists.stepper.Step
import com.ven.assists.stepper.StepCollector
import com.ven.assists.stepper.StepImpl
import com.ven.assists.window.AssistsWindowManager.overlayToast
import kotlinx.coroutines.delay

class SimpleStep: StepImpl() {
    override fun onImpl(collector: StepCollector) {
        collector.next(stepTag = 1){
            //第1步

            "点击搜索".overlayToast()
            delay(1000)
            AssistsCore.findById("com.tencent.mm:id/jha").firstOrNull()?.click()

            //执行第2步
            return@next Step.get(2, delay = 2000)
        }.next(stepTag = 2){
            //第2步

            "输入搜索内容".overlayToast()
            delay(1000)

            AssistsCore.findByTags("android.widget.EditText").firstOrNull()?.setNodeText("自动输入的搜索内容")

            //结束执行
            return@next Step.none
        }
    }
}